<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>修改业主信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
    <script src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>

<body>
<div class="layui-fluid">
    <div class="layui-row" style="margin-left: 30%">
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>id</label>
                <div class="layui-input-inline">
                    <input type="text" readonly="readonly" id="oid" required="" autocomplete="off" class="layui-input"></div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>姓名</label>
                <div class="layui-input-inline">
                    <input type="text" id="oname" required="" autocomplete="off" class="layui-input"></div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>性别</label>
                <div class="layui-input-inline">
                    <input type="text" id="osex" name="username" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>年龄</label>
                <div class="layui-input-inline">
                    <input type="text" id="oage" name="username" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>人口</label>
                <div class="layui-input-inline">
                    <input type="text" id="oparent" name="username" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>身份证号</label>
                <div class="layui-input-inline">
                    <input type="text" id="onumber" name="username" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>手机</label>
                <div class="layui-input-inline">
                    <input type="text" id="ophone" name="username" required="" lay-verify="nikename" autocomplete="off"
                           class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>工作单位</label>
                <div class="layui-input-inline">
                    <input type="text" id="ocompany" name="username" required="" lay-verify="nikename"
                           autocomplete="off" class="layui-input"></div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" id="butt" lay-filter="add" id="butt">修改</button>
            </div>
        </div>
    </div>
</div>
<script>layui.use(['form', 'layer'],
    function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
    });</script>

</body>

</html>
<script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
<script>
    layui.use(['table', 'jquery'], function () {
        var table = layui.table;
        var $ = layui.jquery;
        $("#oid").click(function (){
            layer.msg('业主id不能修改!',{
                icon:1
                ,time:1000
            });
        })
        $.ajax({
            type: 'POST',
            url: "http://localhost:8080/api/updateuser",
            data: {"id": sessionStorage.getItem("o_id")},
            headers: {
                token: localStorage.getItem("token")
            },
            datatype: "json",
            success: function (data) {
                let o_id = sessionStorage.getItem("o_id")
                let o_name = sessionStorage.getItem("o_name")
                let o_sex = sessionStorage.getItem("o_sex")
                let o_agr = sessionStorage.getItem("o_agr")
                let o_parent = sessionStorage.getItem("o_parent")
                let o_number = sessionStorage.getItem("o_number")
                let o_phone = sessionStorage.getItem("o_phone")
                let o_company = sessionStorage.getItem("o_company")
                $("#oname").val(o_name);
                $("#osex").val(o_sex);
                $("#oage").val(o_agr);
                $("#oparent").val(o_parent);
                $("#onumber").val(o_number);
                $("#ophone").val(o_phone);
                $("#ocompany").val(o_company);
                $("#oid").val(o_id);
            }
        })
    })
    $("#butt").click(function () {
        layui.use(['table', 'jquery'], function () {
            var table = layui.table;
            var $ = layui.jquery;
            let o_id = $("#oid").val();
            let o_name = $("#oname").val();
            let o_sex = $("#osex").val();
            let o_agr = $("#oage").val();
            let o_parent = $("#oparent").val();
            let o_number = $("#onumber").val();
            let o_phone = $("#ophone").val();
            let o_company = $("#ocompany").val();
            $.ajax({
                type: "POST",
                url: "http://localhost:8080/api/updatesuser",
                data: {
                    "oId": o_id,
                    "oName": o_name,
                    "oSex": o_sex,
                    "oAge": o_agr,
                    "oParent": o_parent,
                    "oNumber": o_number,
                    "oPhone": o_phone,
                    "oCompany": o_company
                },
                headers: {
                    token: localStorage.getItem("token")
                },
                datatype: "json",
                success: function (data) {
                    if (data) {
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg('业主信息修改成功!',{
                            icon:1
                            ,time:1000
                        },function (){
                            parent.layer.close(index);//关闭当前页
                        });
                    }
                }
            })
        })
    })

</script>